package com.cgsd.heyu.adapter;

import android.content.Context;
import android.view.View;
import android.widget.ImageView;

import com.android.library.adapter.BaseMultiItemAdapter;
import com.android.library.adapter.ViewHolder;
import com.android.library.utils.StringUtils;
import com.cgsd.heyu.R;
import com.cgsd.heyu.entity.TabEntity;

import java.util.List;

/**
 * Description : 设置数据
 *
 * @author : shaohua
 * 时间：2019/11/21 16
 * 邮箱：only_dream136@sina.com
 */
public class CenterContentAdapter extends BaseMultiItemAdapter<TabEntity> {

    public CenterContentAdapter(Context mContext, List<TabEntity> mDatas) {
        super(mContext, mDatas);
    }

    @Override
    protected int muItemViewType(int position, TabEntity tabEntity) {
        return 0;
    }

    @Override
    protected int muLayoutId(int itemType) {
        return R.layout.item_center_content;
    }

    @Override
    public void convert(ViewHolder holder, TabEntity tabEntity, final int position) {
        holder.setText(R.id.tv_title, tabEntity.title);
        ImageView ivBg = holder.getView(R.id.mIvImage);
        if (tabEntity.imgResId != 0) {
            ivBg.setImageResource(tabEntity.imgResId);
            ivBg.setVisibility(View.VISIBLE);
        } else {
            ivBg.setVisibility(View.GONE);
        }
        if (StringUtils.isEmpty(tabEntity.other)) {
            holder.setText(R.id.tv_number, "");
        } else {
            holder.setText(R.id.tv_number, tabEntity.other);
        }
    }
}
